package com.framework.service.core.controller;

import com.framework.service.core.service.IFileService;
import com.framework.core.api.response.UploadRes;
import com.framework.service.core.service.IFileService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author zhoubb
 * @version V1.0
 * @Date 2020/5/16 15:37
 * @since JDK 1.8
 */
@RestController
@RequestMapping("/api/upload")
@Api(value = "uploadApi", description = "文件上传接口")
public class UploadController {

    @Autowired
    private IFileService fileService;


    @ApiOperation(value = "普通文件上传", httpMethod = "POST")
    @RequestMapping(value = "/uploadOpenFile",method = RequestMethod.POST)
    @ResponseBody
    public UploadRes uploadOpenFile(@ApiParam(value = "文件") MultipartFile file) {
        return fileService.uploadOpenFileToOss(file);
    }

    @ApiOperation(value = "敏感文件上传", httpMethod = "POST")
    @RequestMapping(value = "/uploadFile",method = RequestMethod.POST)
    @ResponseBody
    public UploadRes uploadFile(@ApiParam(value = "文件") MultipartFile file) {
        return fileService.uploadFileToOss(file);
    }
}
